#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

bool cmp(string s1,string s2)
{
    return s1+s2>s2+s1;
}

int main()
{
    int n;
    while (cin>>n)
    {
        vector<string>l(n);
        for (int i=0;i<n;i++)
        {
            cin>>l[i];
        }
        sort(l.begin(),l.end(),cmp);
        for (string i:l)
            cout<<i;
        cout<<endl;
    }
}
